<?php
namespace app\index\controller;

use think\Request;

use app\index\model\questionImage as QuestionImageModel;

class QuestionImage
{
    public function saveQuestionImage($questionImage, $photoList)
    {
        $message = "";
        if ($questionImage->saveAll($photoList)) {
            $message .= "add photoes success";
        }
        else {
            $message .= "add photoes fail";
        }
        return $message;
    }
    //获取问题的相关图片
    public function getQuestionImage(Request $request)
    {
        //获取请求参数
        $questionToken = $request->param("questionToken");

        //查询数据
        $questionImage = QuestionImageModel::all(["questionToken" => $questionToken]);
        $questionImages = [];
        foreach ($questionImage as $key => $value) {
            $questionImages[] = $value["imgUrl"];
        }
        //返回数据
        $JsonData = controller("index/JsonData");
        $json = $JsonData->getJsonData(0, "success", $questionImages);
        return $json;
    }
}